// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-6-24

#ifndef __CHECKBOX_H_COMMON_UI__
#define __CHECKBOX_H_COMMON_UI__

#pragma once

#include "wnd.h"

class CJoyCheckBox;

//##ModelId=44C4B607000F
class CJoyCheckGroup
{
public:
	//##ModelId=44C4B6070020
    CList<CJoyCheckBox*>    m_boxs;
	//##ModelId=44C4B6070024
    bool m_autoCheck;
	//##ModelId=44C4B6070025
    bool m_autoUncheck;
public:
	//##ModelId=44C4B607002E
    CJoyCheckGroup();
	//##ModelId=44C4B607002F
    virtual ~CJoyCheckGroup();

	//##ModelId=44C4B6070031
    void Add(CJoyCheckBox* box);
	//##ModelId=44C4B6070033
    void Remove(CJoyCheckBox* box);
	//##ModelId=44C4B607003E
    void Check(CJoyCheckBox* box);
	//##ModelId=44C4B6070040
    void CheckFirstVisible();

	//##ModelId=44C4B6070041
    CJoyCheckBox* GetSel();

	//##ModelId=44C4B6070042
    void ShowAll(bool show);
};

//##ModelId=44C4B607005D
class CJoyCheckBox :
    public CJoyCtrl
{
public:
	//##ModelId=44C4B60700DB
    typedef void (CJoyWnd::*PCheckEvent)(CJoyCheckBox*, bool& checked);
protected:

    friend class CJoyCheckGroup;

	//##ModelId=44C4B607005F
    bool    m_checked;
	//##ModelId=44C4B607006D
    bool    m_btnDown;
	//##ModelId=44C4B607006E
    bool    m_leftDownCheck;

	//##ModelId=44C4B6070070
    CJoyImagePtr    m_image;
	//##ModelId=44C4B607007E
    CJoyCheckGroup* m_group;

	//##ModelId=44C4B6070083
    PCheckEvent     m_onCheck;
	//##ModelId=44C4B607008D
    CJoyWnd*        m_eventCtrl;

	//##ModelId=44C4B6070091
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);

	//##ModelId=44C4B607009C
    virtual void CM_MouseHover();
	//##ModelId=44C4B607009E
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
	//##ModelId=44C4B60700A2
    virtual void CM_Draw(Graphics& graph);
	//##ModelId=44C4B60700AD
    virtual void CM_Destroy();

public:
	//##ModelId=44C4B60700AF
    bool    m_autoUncheck;
public:
	//##ModelId=44C4B60700BB
    CJoyCheckBox(void);
	//##ModelId=44C4B60700BD
    virtual ~CJoyCheckBox(void);

	//##ModelId=44C4B60700C0
    bool IsChecked() const
    {
        return m_checked;
    }
	//##ModelId=44C4B60700C2
    CJoyCheckGroup* GetGroup() const
    {
        return m_group;
    }
	//##ModelId=44C4B60700CB
    void SetCheck(bool checked);
	//##ModelId=44C4B60700CD
    void SetCheckEvent(CJoyWnd* ctrl, PCheckEvent onCheck);
	//##ModelId=44C4B60700D0
    void SetImage(PCTSTR pszImage);
};


#endif  // __CHECKBOX_H_COMMON_UI__
